﻿using Mate.Framework.Extensions;
using Mate.Framework.Infrastructure;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Text;

namespace Mate.Framework.BaseController.Admin
{
    [AdminAuthentication]
    [AdminAuthorization]
    public class BaseController: Controller
    {
       // private int _currentAdminUserId;
        private bool? _isSuperAdmin;


        #region 获取当前登录用户ID
        /// <summary>
        /// 获取当前登录用户ID
        /// </summary>
        //protected int CurrentAdminUserId
        //{
        //    get
        //    {
        //        if (_currentAdminUserId > 0)
        //        {
        //            return _currentAdminUserId;
        //        }
        //        _currentAdminUserId = HttpContext.User.Identity.Id();
        //        return _currentAdminUserId;
        //    }
        //}
        #endregion

        #region 获取当前登录用户是否超级管理员
        /// <summary>
        /// 获取当前登录用户是否超级管理员
        /// </summary>
        protected bool IsSuperAdmin
        {
            get
            {
                if (_isSuperAdmin != null)
                {
                    return _isSuperAdmin.Value;
                }
                _isSuperAdmin = HttpContext.User.Identity.UserName()=="admin";
                return _isSuperAdmin.Value;
            }
        }
        #endregion

    }
}
